package com.prj.controller;

import com.prj.common.core.controller.BaseController;
import com.prj.common.core.domain.AjaxResult;
import com.prj.common.core.page.TableDataInfo;
import com.prj.domain.Dept;
import com.prj.domain.EmpWork;
import com.prj.service.IEmpWorkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/emp_work")
@Api(tags = "工作记录")
public class EmpWorkController extends BaseController {
    @Autowired
    private IEmpWorkService empWorkService;


    @GetMapping("/list")
    @ApiOperation(value = "查询员工列表")
    public TableDataInfo list(EmpWork empWork){
        startPage();
        List<EmpWork> list = empWorkService.selectEmpWorkList(empWork);
        return getDataByPage(list);
    }

    @GetMapping(value = "/{id}")
    public TableDataInfo getInfo(@PathVariable("id") Long id)
    {
        List<EmpWork> list = empWorkService.selectEmpWorkById(id);
        return getDataByPage(list);
    }

    @PostMapping
    @ApiOperation(value = "新增员工工作记录")
    public AjaxResult add(@RequestBody EmpWork empWork){
        return toAjax(empWorkService.insertEmpWork(empWork));
    }



    @PutMapping
    @ApiOperation(value = "修改员工工作记录")
    public AjaxResult edit(@RequestBody EmpWork empWork){

        return toAjax(empWorkService.updateEmpWork(empWork));
    }

    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除员工工作记录")
    public AjaxResult remove(@PathVariable Long[] ids){
        return toAjax(empWorkService.deleteEmpWorkByIds(ids));
    }
}
